﻿using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using Rsdn.Janus.ObjectModel;
using Rsdn.SmartApp;

namespace Rsdn.Janus
{
    [Service(typeof(IIncomingFolderUpdate))]
    internal class IncomingFolderUpdate : IIncomingFolderUpdate, IDisposable
    {
        private readonly IServiceProvider _provider;
        private List<Feature> additionalUpdates = new List<Feature>();

        public IncomingFolderUpdate([NotNull] IServiceProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            _provider = provider;
        }

        public void Dispose()
        {

        }

        public void AddUpdate(Feature forum)
        {
            // as we have small list of updates it is not need to use dictionary
            if (additionalUpdates.IndexOf(forum) < 0)
            {
                additionalUpdates.Add(forum);
            }
        }

        public IEnumerable<Feature> GetUpdates
        {
            get
            {
                return additionalUpdates;
            }
        }

    }
}